class WinComponent extends eui.Component {

    public constructor(next: Function) {
        super();
        this.skinName = "WinComponentSkin";
        this.addEventListener(egret.Event.ADDED_TO_STAGE, this.addToStage, this);
        if (typeof next === 'function') {
            this.addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
                next.call(this);
            }, this);
        }
    }

    private addToStage() {
        const {stageWidth, stageHeight} = this.stage;

        const successPng = createBitmapByName("success_png");
        const successW = stageWidth - 64;
        const spW = successPng['$bitmapWidth'];
        const spH = successPng['$bitmapHeight'];
        const successH = scaleHeight(spW, spH, successW);
        const successX = (stageWidth - successW) / 2;
        const successY = (stageHeight - successH) / 2;
        successPng.width = successW;
        successPng.height = successH;
        successPng.x = successX;
        successPng.y = successY;
        this.addChild(successPng);
        const tipW = successW - 20;
        const titleFromX = (stageWidth - tipW) / 2;
        const titleFromY = successH / 2 + successY;

        const tipText = new egret.TextField();
        tipText.text = '恭喜！闯关成功';
        tipText.textColor = ColorWhite;
        tipText.size = 36;
        tipText.width = tipW;
        tipText.bold = true;
        tipText.textAlign = egret.HorizontalAlign.CENTER;
        tipText.x = titleFromX;
        tipText.y = titleFromY - (tipText.height / 2);
        this.addChild(tipText);
    }
}
